import java.util.concurrent.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-09-07
 * Time: 16:15
 */
public class demo1 {
    public static void main(String[] args) throws InterruptedException {
        ExecutorService executor = Executors.newCachedThreadPool();
        for (int i = 0; i < 100; i++) {
            int id = i;
            executor.submit(() -> {
                //执行的任务
                Thread cur = Thread.currentThread();
                System.out.println("Hello Thread " + id + " " + cur.getName());
            });
        }
        Thread.sleep(3000);
        executor.shutdown();
        System.out.println("程序退出");
    }
}